package com.example.clxy.controller;

import com.example.clxy.entity.School;
import com.example.clxy.interceptor.AppToken;
import com.example.clxy.result.PageResult;
import com.example.clxy.result.WebRestResult;
import com.example.clxy.result.business.PageResult.SchoolPageResult;
import com.example.clxy.service.SchoolService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author Hsieh
 * @title: SchoolController
 * @projectName clxy
 * @description:
 * @date 2020/8/129:11
 */
@AppToken
@RestController
@RequestMapping("SchoolController")
public class SchoolController {
    @Autowired
    SchoolService schoolService;

    /**
     * @param
     * @Author:hsieh
     * @Date: 2020/8/10 21:34
     * @Description:添加院校
     */
    @CrossOrigin
    @PostMapping("addSchool")
    public WebRestResult addSchool(@RequestBody School school) {
        WebRestResult result = schoolService.addSchool(school);
        return result;
    }

    @CrossOrigin
    @PostMapping("deleteSchool")
    public WebRestResult deleteSchool(String Schoolid) {
        WebRestResult result = schoolService.deleteSchool(Schoolid);
        return result;
    }

    @CrossOrigin
    @PostMapping("updateSchool")
    public WebRestResult updateSchool(@RequestBody School school) {
        WebRestResult result = schoolService.updateSchool(school);
        return result;
    }

    @CrossOrigin
    @RequestMapping("getSchoolbyname")
    public PageResult<SchoolPageResult> getschoolbyname(String schoolname, int page, int pagesize) {
        PageResult<SchoolPageResult> result = schoolService.getSchoolbyname(schoolname, page, pagesize);
        return result;
    }

    @CrossOrigin
    @RequestMapping("getSchoolbyid")
    public PageResult<SchoolPageResult> getschoolbyid(String schoolid, int page, int pagesize) {
        PageResult<SchoolPageResult> result = schoolService.getSchoolbyid(schoolid, page, pagesize);
        return result;
    }

}

